//
// Created by jsjxsy on 2022/8/11.
//
#include <memory>
#include <iostream>
using namespace std;
class A {
 public:
  A();
  ~A();
  int score = 10;
 private:

};
A::A() {
  cout << "A()" << endl;
}
A::~A() {
  cout << "~A()" << endl;
}
int main(void){
  auto p1 = shared_ptr<A>(new A());
  cout<<"p1="<<p1.get()<<endl;
  //
  auto p2 = move(p1);
  cout<<"p1="<<p1.get()<<endl;
  cout<<"p2="<<p2.get()<<endl;
  //
  auto p3 = p2;
  cout<< "p2.use_count()="<<p2.use_count()<<endl;
  cout<< "p3.use_count()="<<p3.use_count()<<endl;
  p2.reset();
  cout<<"p2="<<p2.get()<<endl;
  cout<< "p2.use_count()="<<p2.use_count()<<endl;
  cout<< "p3.use_count()="<<p3.use_count()<<endl;
  shared_ptr<A> p4 (new A());
  auto p5 = std::make_shared<int>(10);
  cout<<"p5="<<*(p5.get())<<endl;
  return 0;
}